﻿<extend name="Public:office" />
<block name="title"><title>团队信息</title></block>
<block name="header_styles">
    <link rel="stylesheet" href="__Public__/kindeditor/themes/default/default.css" />
    <style type="text/css">
        .main-wrapper .container {
            background-color: #ffffff;
        }

        iframe.photo {
            margin: 0px;
        }
    </style>
</block>
<block name="main">
    <div class="tabs-wrapper">
        <include file="Team:menu" />
        <div class="tab-content">
            <div class="tab-pane active" style="min-height: 600px;">
                <input type="hidden" id="teamId" value="{$userinfo.teamid}" />
                <div id="phPreview">
                    <if condition="($creater eq 1) or ($editor eq 1)">
                        <div class="dropdown pull-right">
                            <a id="dLabel" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="dropdown-button"><i class="fa fa-cog"></i></a>
                            <ul class="dropdown-menu" aria-labelledby="dLabel">
                                <li><a href="#" id="btnEditTeamInfo">编辑</a></li>
                                <li><a href="#" id="btnDismassTeam">解散</a></li>
                            </ul>
                        </div>
                    </if>
                    <div class="row">
                        <div class="col-xs-3">
                            <if condition="$arr.logo eq ''">
                                <img src="__APP__/Public/themes/images/LOGO-gray.png" width="200" height="200" class="img-thumbnail" />
                                <else />
                                <img src="__APP__/{$arr.logo}" width="200" height="200" class="img-thumbnail" />
                            </if>
                        </div>
                        <div class="form-horizontal col-xs-6 label-align-left">
                            <div class="form-group">
                                <label class="control-label col-xs-3">团队名称</label>
                                <div class="col-xs-9">
                                    <p class="form-control-static">{$arr.name}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-3">项目简介</label>
                                <div class="col-xs-9">
                                    <p class="form-control-static">{$arr.pabstract|htmlspecialchars_decode|strip_tags}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-3">官方微博</label>
                                <div class="col-xs-9">
                                    <p class="form-control-static">{$arr.weibo}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-3" style="white-space: nowrap;">微信公众号</label>
                                <div class="col-xs-9">
                                    <p class="form-control-static">{$arr.weixin}</p>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-3">是否公开</label>
                                <div class="col-xs-9">
                                    <p class="form-control-static">
                                        <if condition="$arr.power eq 1">保密</if>
                                        <if condition="$arr.power eq 2">公开</if>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="phEditable" style="display:none;">

                    <if condition="$userinfo.teamid eq -1">
                        <h3 class="text-center">填写信息创建团队</h3>
                        <else />
                        <a href="#" class="dropdown-button pull-right" title="取消编辑" id="btnCancelEdit"><i class="fa fa-times"></i></a>
                    </if>
                    <div class="row">
                        <form method="post" action="" id="formEditable">
                            <div class="form-horizontal col-xs-7 label-align-left" id="divUploader">
                                <div class="form-group">
                                    <label class="control-label col-xs-3">团队logo</label>
                                    <div class="col-xs-9">
                                        <div id="croppic">
                                            <iframe src="{:U('/Index/sp')}" scrolling="no" frameborder="0" width="502" height="360" class="photo"></iframe>
                                            <input type="hidden" id="userpic" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            <div class="form-horizontal col-xs-7 label-align-left">
                                <div class="form-group">
                                    <label class="control-label col-xs-3">团队名称</label>
                                    <div class="col-xs-9">
                                        <neq name="userinfo.teamid" value="-1">
                                            <input type="text" class="form-control" placeholder="给你的项目起个响亮的名字吧！中英文都可以哦" name="teamname" id="teamname" data-val="true" data-val-required="团队名称不能为空" value="{$arr.name}" maxlength="30" disabled='disabled' />
                                            <else />
                                            <input type="text" class="form-control" placeholder="给你的项目起个响亮的名字吧！中英文都可以哦" name="teamname" id="teamname" data-val="true" data-val-required="团队名称不能为空" value="{$arr.name}" maxlength="30" />
                                        </neq>
                                        <span class="help-block"> *设置后将不能再次更改</span>
                                        <span data-valmsg-for="teamname" data-valmsg-replace="true"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label  col-xs-3">项目简介</label><span data-valmsg-for="abstract" data-valmsg-replace="true"></span>
                                    <div class="col-xs-9">
                                        <textarea type="text" class="form-control" name="pabstract" id="pabstract" style="width:100px;"
                                                  data-val="true" rows="10" data-val-required="项目简介不能为空" maxlength="200"
                                                  placeholder="请简要描述您所发布的项目的具体内容，可以包含项目简介，完成时间，验收标准等，200字以内。">
                                            {$arr.pabstract}
                                        </textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-xs-3">官方微博</label>
                                    <div class="col-xs-9">
                                        <input type="text" class="form-control" name="weibo" id="weibo" value="{$arr.weibo}" placeholder="选填" maxlength="50" />
                                        <span data-valmsg-for="weibo" data-valmsg-replace="true"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-xs-3" style="white-space: nowrap;">微信公众号</label>
                                    <div class="col-xs-9">
                                        <input type="text" class="form-control" name="weixin" id="weixin" value="{$arr.weixin}" placeholder="选填" maxlength="50" />
                                        <span data-valmsg-for="weixin" data-valmsg-replace="true"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-xs-12">是否公开(选择公开，则您发布的信息展示在项目库中。选择保密，则您发布的信息不会展示在项目库，人才也不可申请加入)</label>
                                    <div class="col-xs-12">
                                        <if condition="$arr.power eq 1">
                                            <label class="radio-inline"><input type="radio" name="power" checked value="1" />保密 </label>&nbsp;
                                            <label class="radio-inline"><input type="radio" name="power" value="2" />公开 </label>
                                            <else />
                                            <label class="radio-inline"><input type="radio" name="power" value="1" />保密 </label>&nbsp;
                                            <label class="radio-inline"><input type="radio" name="power" checked value="2" />公开 </label>
                                        </if>
                                    </div>
                                </div>
                                <input type="hidden" value="{$arr.power}" id="power" />
                                <div class="form-buttons text-center">
                                    <if condition="$userinfo.teamid eq -1">
                                        <button type="submit" class="btn btn-success" id="btnSaveTeamInfo">下一步</button>
                                        <else />
                                        <button type="submit" class="btn btn-success" id="btnSaveTeamInfo">保存</button>
                                    </if>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="footer_scripts">
    <!--<script src="__Public__/js/location_cn.js"></script>-->
    <script type="text/javascript" src="__Public__/kindeditor/kindeditor-all-min.js"></script>
    <script type="text/javascript" src="__Public__/kindeditor/lang/zh_CN.js"></script>
    <script type="text/javascript">
        function photoCropCompleted(url) {
            $("#userpic").val(url);
        }

        function resetButtonClick() {
            $("#userpic").val("");
        }
    </script>

    <script type="text/javascript">
        require(["jquery", "modules/message", "libraries/common"], function ($, messageBox) {
            var editor;

            $(function () {
                if ($("#teamId").val() == "-1") {
                    $("#phPreview").hide();
                    $("#phEditable").show();
                }

                $("#btnEditTeamInfo").click(function () {
                    $("#phPreview").hide();
                    $("#phEditable").fadeIn();
                    $(".dropdown-button").dropdown('toggle');
                    return false;
                });

                $("#btnCancelEdit").click(function () {
                    $("#phPreview").fadeIn();
                    $("#phEditable").hide();
                    return false;
                });


                $("#btnSaveTeamInfo,#btnSaveTeamInfo2").click(function () {
                    if (!$("#formEditable").valid()) {
                        return false;
                    }
                    saveTeaminfo();
                    return false;
                });

                //解散团队
                $("#btnDismassTeam").click(function () {
                    messageBox.confirm({
                        content: '确定要解散团队吗?', sure: function () {
                            var url = "{:U('Team/dismassTeam_ajax')}";
                            $.post(url, {}, function (data) {
                                var vdata = eval(data);
                                messageBox.alert({
                                    content: vdata.msg,
                                    sure: function () {
                                        if (vdata.success == 1) {
                                            window.location.reload();
                                        } else {
                                            messageBox.close();
                                        }
                                    }
                                });
                            }, 'json');
                        }
                    });
                    return false;
                });
                //初始化KindeEditor
                var K = window.KindEditor;
                editor = K.create('textarea[name="pabstract"]', {
                    resizeType: 1,
                    height: 300,
                    allowPreviewEmoticons: false,
                    allowImageUpload: false,
                    items: [
                            'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                            'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                            'insertunorderedlist', '|', 'emoticons', 'image', 'link']
                });
            });


            function saveTeaminfo() {
                editor.sync();
                var url = "{:U('Team/teaminfo_ajax')}";
                var uid = parseInt("{$uid}");
                var logo = $('#userpic').val();
                var teamname = $('#teamname').val();
                var pname = $('#prjname').val();
                var pabstract = $('#pabstract').val();
                var weibo = $('#weibo').val();
                var weixin = $('#weixin').val();
                var power = $('input[name="power"]:checked').val();

                var postData = {
                    logo: logo,
                    teamname: teamname,
                    pname: pname,
                    pabstract: pabstract,
                    weixin: weixin,
                    weibo: weibo,
                    power: power,
                    uid: uid
                };

                $.post(url, postData, function (data) {
                    var vdata = eval(data);
                    if (vdata.success == 1) {
                        if ($("#teamId").val() == "-1") {
                            window.location.href = "{:U('Team/jobs','','')}-teamid-" + vdata.msg;
                        } else {
                            messageBox.alert({ title: '提示', content: "保存成功", sure: function () { window.location.reload(); } });
                        }
                    }
                    else {
                        messageBox.alert({ title: '保存失败', content: data.msg, sure: function () { window.location.reload(); } });
                    }
                    $("#phPreview").hide();
                    $("#phEditable").show();
                }, 'json');
            }
        });

    </script>
</block>
